package com.shikong.blog.controller;


import com.shikong.blog.aspect.ApiOperationLog;
import com.shikong.blog.common.Response;
import com.shikong.blog.model.systemvo.blogsetting.UpdateBlogMineReqVO;
import com.shikong.blog.model.systemvo.blogsetting.UpdateBlogSettingReqVO;
import com.shikong.blog.service.AdminBlogMineService;
import com.shikong.blog.service.AdminBlogSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 后端博客设置管理
 **/
@RestController
@RequestMapping("/admin/blog")
public class AdminBlogSettingController {

    @Autowired
    private AdminBlogSettingService blogSettingService;

    @Autowired
    private AdminBlogMineService blogMineService;

    @PostMapping("/setting/update")
    @ApiOperationLog(description = "更新博客设置信息")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public Response updateBlogSetting(@RequestBody @Validated UpdateBlogSettingReqVO updateBlogSettingReqVO) {
        return blogSettingService.updateBlogSetting(updateBlogSettingReqVO);
    }

    @PostMapping("/setting/detail")
    @ApiOperationLog(description = "获取博客设置详情信息")
    public Response queryBlogSettingDetail() {
        return blogSettingService.queryBlogSettingDetail();
    }

    @PostMapping("/mine/update")
    @ApiOperationLog(description = "更新博客设置信息")
    @PreAuthorize("hasRole('ROLE_ADMIN')")
    public Response updateBlogMine(@RequestBody @Validated UpdateBlogMineReqVO updateBlogMineReqVO) {
        return blogMineService.updateBlogMine(updateBlogMineReqVO);
    }

    @PostMapping("/mine/detail")
    @ApiOperationLog(description = "获取博客设置详情信息")
    public Response queryBlogMineDetail() {
        return blogMineService.queryBlogMineDetail();
    }
}
